﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace OF.Lib.DataAccess.Entity
{
    [Serializable]
    [XmlRoot]
    public class SQLConfig
    {
        [XmlArrayItem("SQL")]
        public List<SQL> SQLList { get; set; }

    }

    [Serializable]
    public class SQL
    {
        [XmlAttribute]
        public string SQLKey { get; set; }

        [XmlAttribute]
        public string ConnKey { get; set; }

        [XmlAttribute]
        public int TimeOut { get; set; }

        [XmlAttribute]
        public string MasterDB { get; set; }

        [XmlElement]
        public string Text { get; set; }

        /// <summary>
        /// 只要没有显式的添加MasterDB="false"，那么就返回true，认为是访问主库
        /// </summary>
        [XmlIgnore]
        public bool IsMasterDB
        {
            get
            {
                if(!string.IsNullOrWhiteSpace(MasterDB) && MasterDB.Trim().ToUpper()=="FALSE")
                {
                    return false;
                }
                return true;
            }
        }
    }
}
